<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script>
    
        var o = {
            extend:function() {
                for(var i = 0;i<arguments.length;i++){
                    //分别取出传入的对象，将传入的对象属性遍历给当前对象（继承给当前对象）
                    for(var k in arguments[i]) {
                        //i 表示传入的是第几个对象，k是这个对象的属性
                        this[k] = arguments[i][k];
                    }
                }
            }
        }
        
        o.extend(
            {name:'zs',age:18},
            {
                sayHi:function() {
                    console.log('你好啊');                    
                },
                walk:function() {
                    console.log('行走');                    
                }
             }
        )
        console.log(o);
        
        //继承了属性和方法
        o.walk();
    </script>
</body>
</html>